//package com.cg.managesystem.config;
//
//import com.cg.managesystem.entity.User;
//import com.cg.managesystem.mapper.UserMapper;
//import org.apache.el.stream.Optional;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**+
// * Create tao on 2019/8/13
// */
//public class BytreesUserDetailService implements UserDetailsService {
//
//    @Autowired
//    private UserMapper userMapper;
//
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        Optional<User> users = userRepository.findByName(username);
//        if (!users.isPresent()) {
//            throw new UsernameNotFoundException("user not exists.");
//        }
//        List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
//        authList.add(new SimpleGrantedAuthority("ROLE_USER"));
//        UserDetails userDetail = new User(users.get().getName(), users.get().getPassword(), authList);
//        return userDetail;
//    }
//
//
//}
//}
